package catchData.notWellDone;

import java.io.IOException;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.log4j.Logger;

import util.CatchDataUtil;

public class Catch4chinaemed {

	private static Logger LOG = Logger.getLogger("Catch4chinaemed");
	private static HttpClient client;
	private static final String MAIN_PAGE = "http://ca.chinaemed.com/Login.ashx";
	private static final String LOGIN_PAGE = "http://bid.chinaemed.com/Base/NotLogin.mvc";
	private static final String USERNAME = "wendiya";
	private static final String PASSWORD = "665544";
	private static CatchDataUtil catchData = new CatchDataUtil();
	
	public static void main(String[] args) {
		HttpClient client = catchData.initHttpClient();
		GetMethod get = new GetMethod(LOGIN_PAGE);
		NameValuePair username = new NameValuePair("textfield", USERNAME);
		NameValuePair password = new NameValuePair("textfield2", PASSWORD);
//		PostMethod post = new PostMethod(MAIN_PAGE);
		try {
			catchData.setHeaders(get,LOGIN_PAGE,catchData.getWebSite(LOGIN_PAGE));
			client.executeMethod(get);
//			post.setRequestBody(new NameValuePair[] {username, password});
//			catchData.setHeaders(post,MAIN_PAGE,catchData.getWebSite(MAIN_PAGE));
//			client.executeMethod(post);
//			System.out.println(get.getResponseBodyAsString());
//			post.releaseConnection();
			get.releaseConnection();
			
			//http://ca.chinaemed.com/Home/validateImage/System.Web.Mvc.UrlParameter.mvc验证码
		} catch (HttpException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
}
